/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.pacis.shca.domain.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author solriver
 */
@Entity
@Table(name = "miembro", catalog = "bdshca")
@NamedQueries({
    @NamedQuery(name = "Miembro.findAll", query = "SELECT m FROM Miembro m"),
    @NamedQuery(name = "Miembro.findByIdMiembro", query = "SELECT m FROM Miembro m WHERE m.idMiembro = :idMiembro"),
    @NamedQuery(name = "Miembro.findByMieFallecido", query = "SELECT m FROM Miembro m WHERE m.mieFallecido = :mieFallecido"),
    @NamedQuery(name = "Miembro.findByMieAdoptado", query = "SELECT m FROM Miembro m WHERE m.mieAdoptado = :mieAdoptado")})
public class Member implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_miembro")
    private Integer id;
    @Column(name = "mie_fallecido")
    private Boolean deceased;
    @Column(name = "mie_adoptado")
    private Boolean adopted;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<MedicalAssurance> medicalAssurances;
    @JoinColumn(name = "per_id_madre", referencedColumnName = "id_persona")
    @ManyToOne(optional = false)
    private Person mother;
    @JoinColumn(name = "per_id_padre", referencedColumnName = "id_persona")
    @ManyToOne(optional = false)
    private Person father;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<HealthObservation> healthObservations;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<Instruction> instructions;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "headHousehold")
    private List<FamilyGroup> familyGroups;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<Occupation> occupations;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<GroupRecord> groupRecords;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "member")
    private Person person;

    public Member() {
    }

    public Member(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Boolean getDeceased() {
        return deceased;
    }

    public void setDeceased(Boolean deceased) {
        this.deceased = deceased;
    }

    public Boolean getAdopted() {
        return adopted;
    }

    public void setAdopted(Boolean adopted) {
        this.adopted = adopted;
    }

    public List<MedicalAssurance> getMedicalAssurances() {
        return medicalAssurances;
    }

    public void setMedicalAssurances(List<MedicalAssurance> medicalAssurances) {
        this.medicalAssurances = medicalAssurances;
    }

    public Person getMother() {
        return mother;
    }

    public void setMother(Person mother) {
        this.mother = mother;
    }

    public Person getFather() {
        return father;
    }

    public void setFather(Person father) {
        this.father = father;
    }

    public List<HealthObservation> getHealthObservations() {
        return healthObservations;
    }

    public void setHealthObservations(List<HealthObservation> healthObservations) {
        this.healthObservations = healthObservations;
    }

    public List<Instruction> getInstructions() {
        return instructions;
    }

    public void setInstructions(List<Instruction> instructions) {
        this.instructions = instructions;
    }

    public List<FamilyGroup> getFamilyGroups() {
        return familyGroups;
    }

    public void setFamilyGroups(List<FamilyGroup> familyGroups) {
        this.familyGroups = familyGroups;
    }

    public List<Occupation> getOccupations() {
        return occupations;
    }

    public void setOccupations(List<Occupation> occupations) {
        this.occupations = occupations;
    }

    public List<GroupRecord> getGroupRecords() {
        return groupRecords;
    }

    public void setGroupRecords(List<GroupRecord> groupRecords) {
        this.groupRecords = groupRecords;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Member)) {
            return false;
        }
        Member other = (Member) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.pacis.shca.domain.entity.Member[ id=" + id + " ]";
    }
    
}
